package cc.marcio.systems.seven.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "t_user", uniqueConstraints = { @UniqueConstraint(columnNames = { "id" }) })
@SequenceGenerator(name = "seq_user", sequenceName = "seq_user")
public class User implements Serializable {

	private static final long serialVersionUID = 3126166615936077765L;

	public static final int ALERT_FOR_ME = 1;
    public static final int ALERT_FOR_GALAXIA = 2;
    public static final int ALERT_FOR_SECTOR = 3;
    public static final int ALERT_FOR_ALL = 4;
    public static final int PERMISSION_PLAYER = 1;
    public static final int PERMISSION_HC = 2;
    public static final int PERMISSION_ADM = 3;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_user")
	@Column( unique = true, insertable = false, updatable = false )
	private Long id;
	
	@Column( nullable = false, unique = false, insertable = true, updatable = true, length = 80 )
	private String name;

	@Column( nullable = false, unique = true, insertable = true, updatable = true, length = 15 )
	private String login;
	
	@Column( nullable = false, unique = false, insertable = true, updatable = true, length = 10 )
	private String password;
	
	@Column( nullable = false, unique = false, insertable = true, updatable = true, length = 80 )
	private String gmailuser;
	
	@Column( nullable = false, unique = false, insertable = true, updatable = true, length = 80 )
	private String gmailpassword;
	
	private Boolean active;
	
	private Boolean isAlertActive;
	
	private Integer alertFor;
	
	@Transient
	private List<Contact> contacts;

	private Integer permission;
	
	public User() {
		this.contacts = new ArrayList<Contact>();
		this.active = true;
	}
	
	public User(Long id) {
		this();
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getGmailuser() {
		return gmailuser;
	}

	public void setGmailuser(String gmailuser) {
		this.gmailuser = gmailuser;
	}

	public String getGmailpassword() {
		return gmailpassword;
	}

	public void setGmailpassword(String gmailpassword) {
		this.gmailpassword = gmailpassword;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public Boolean getIsAlertActive() {
		return isAlertActive;
	}

	public void setIsAlertActive(Boolean isAlertActive) {
		this.isAlertActive = isAlertActive;
	}

	public Integer getAlertFor() {
		return alertFor;
	}

	public void setAlertFor(Integer alertFor) {
		this.alertFor = alertFor;
	}

	public List<Contact> getContacts() {
		return contacts;
	}

	public void setContacts(List<Contact> contacts) {
		this.contacts = contacts;
	}

	public Integer getPermission() {
		return permission;
	}

	public void setPermission(Integer permission) {
		this.permission = permission;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	public String toString() {
		return this.login;
	}
}